﻿namespace KeyStone.EventHub.Utility
{
   using System;

   /// <summary>
   /// Class ValueGuard.
   /// </summary>
   internal static class Guard
   {
      /// <summary>
      /// Throws the argument null exception if null or empty.
      /// </summary>
      /// <param name="target">The target.</param>
      /// <param name="name">The name.</param>
      /// <param name="member">The member.</param>
      /// <exception cref="System.ArgumentNullException">Thrown if target is null or empty</exception>
      internal static void ThrowArgumentNullExceptionIfNullOrEmpty(this string target, string name, string member = "")
      {
         if (string.IsNullOrEmpty(target))
         {
            throw new ArgumentNullException(string.Format("'{0}' called with null or emtpy '{1}' argument",member, name));
         }
      }

      /// <summary>
      /// Throws the argument null exception if null.
      /// </summary>
      /// <typeparam name="T"></typeparam>
      /// <param name="target">The target.</param>
      /// <param name="name">The name.</param>
      /// <param name="member">The member.</param>
      /// <exception cref="System.ArgumentNullException">Thrown if targe is null</exception>
      internal static void ThrowArgumentNullExceptionIfNull<T>(this T target, string name, string member = "")
      {
         if (target == null)
         {
            throw new ArgumentNullException(string.Format("'{0}' called with null '{1}' argument",member,name));
         }
      }
   }

}